﻿<phone:PhoneApplicationPage x:Class="USElections.Calendar.Pages.CalendarPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
                            xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
                            xmlns:model="clr-namespace:USElections.Calendar.Model"
                            xmlns:command="clr-namespace:USElections.Calendar.Command"
                            xmlns:conv="clr-namespace:USElections.Converters;assembly=USElections.Converters"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            mc:Ignorable="d"
                            d:DesignHeight="768"
                            d:DesignWidth="480"
                            shell:SystemTray.IsVisible="True"
                            Style="{StaticResource TransitionPageStyle}">
    <phone:PhoneApplicationPage.Resources>
        <model:ElectionsAppointmentSource x:Key="CalendarAppointments" />
        <conv:TimeHeaderConverter x:Key="TimeHeaderConverter" />
        <command:SetReminderCommand x:Key="setreminder" />
    </phone:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot"
          Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel"
                    Grid.Row="0"
                    Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle"
                       Text="US ELECTIONS"
                       Style="{StaticResource PhoneTextNormalStyle}" />
            <TextBlock x:Name="PageTitle"
                       Text="calendar"
                       Margin="9,-7,0,0"
                       Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>

        <Grid x:Name="ContentPanel"
              Grid.Row="1"
              Margin="12,0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                
                <telerikInput:RadCalendar SelectedValueChanged="RadCalendar_SelectedValueChanged"
                                          Height="400"
                                          MonthInfoDisplayMode="Small"
                                          AppointmentSource="{StaticResource CalendarAppointments}" 
                                          Margin="12" />

                <telerikPrimitives:RadDataBoundListBox x:Name="AppointmentsList"
                                                       Grid.Row="1"
                                                       Margin="12, 0"
                                                       EmptyContent="There are no events for the selected day.">
                    <telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="0,3,0,3">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="96" />
                                    <ColumnDefinition Width="*" />
                                    <!--<ColumnDefinition Width="Auto" />-->
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <toolkit:ContextMenuService.ContextMenu>
                                    <toolkit:ContextMenu>
                                        <toolkit:MenuItem Header="set a reminder"
                                                          Command="{StaticResource setreminder}"
                                                          CommandParameter="{Binding}" />
                                    </toolkit:ContextMenu>
                                </toolkit:ContextMenuService.ContextMenu>

                                <Rectangle Fill="{StaticResource PhoneAccentBrush}"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Top"
                                           Width="8"
                                           Height="32"
                                           Grid.Row="0"
                                           Grid.RowSpan="2"
                                           Margin="0,0,15,0" />
                                
                                <TextBlock Text="{Binding StartDate, Converter={StaticResource TimeHeaderConverter}}"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Top"
                                           Grid.Row="0"
                                           Grid.Column="1"
                                           Grid.RowSpan="2"
                                           Margin="0,-5,0,0" />
                                
                                <TextBlock Text="{Binding Subject}"
                                           FontWeight="Bold"
                                           FontFamily="{StaticResource PhoneFontFamilySemiLight}"
                                           FontSize="{StaticResource PhoneFontSizeSmall}"
                                           Margin="0, -3, 0, -3"
                                           Grid.Row="0"
                                           Grid.Column="2" />
                                
                                <TextBlock Grid.Row="1"
                                           Grid.Column="2"
                                           Text="{Binding Details}"
                                           Style="{StaticResource PhoneTextSubtleStyle}"
                                           TextWrapping="Wrap"
                                           TextTrimming="None"
                                           Margin="0, -5, 0, 0" />
                            </Grid>
                        </DataTemplate>
                    </telerikPrimitives:RadDataBoundListBox.ItemTemplate>
                </telerikPrimitives:RadDataBoundListBox>
            </Grid>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>